package org.apache.rocketmq.client.java.clientapis;

import org.apache.rocketmq.client.java.clientapis.message.MessageBuilder;
import org.apache.rocketmq.client.java.clientapis.producer.ProducerBuilder;

import java.util.Iterator;
import java.util.ServiceLoader;

public interface ClientServiceProvider {
    static ClientServiceProvider loadService(){
        final ServiceLoader<ClientServiceProvider> loads = ServiceLoader.load(ClientServiceProvider.class);
        final Iterator<ClientServiceProvider> iterators = loads.iterator();
        if (iterators.hasNext()){
            return iterators.next();
        }
        throw new UnsupportedOperationException("Client service provider not found" );
    }

    ProducerBuilder newProducerBuilder();

    MessageBuilder newMessageBuilder();

}